﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <script src="scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
    <title></title>
</head>
<body>
<script type="text/javascript">
    //src:http://stackoverflow.com/questions/7466570/jquery-post-does-not-send-json-data
    function sendJSON() {
        var strJSON = "{\"ChuThich\":\"A JSON\",\"KinhDo\":106.6891243,\"MaDichVu\":20,\"MaDuLieu\":9999,\"MaDuong\":410,\"MaPhuong\":146,\"MaQuanHuyen\":46,\"MaTenDiaDiem\":3526,\"MaTinhThanh\":16,\"SoNha\":\"218\/4\",\"ViDo\":10.7774562}";
        var objJSON = JSON.stringify(strJSON);
        alert(strJSON);
        alert(objJSON);
        $.ajax({
            url: "http://localhost:1445/NhaTroService.svc/Add",
			type: "POST",
			contentType: "application/json; charset=utf-8",
            data: objJSON,
            success: function (msg) {
                alert('success');
            }
            /*error: function (x, e) {
                if (x.status == 0) {
                    alert(e);
                }
            }*/
        });
    }
	function InsertNhaTro(){
				var objJSON = JSON.stringify('{"MaDuLieu":5115,"MaTenDiaDiem":"29502312","MaDichVu":20,"SoNha":"123","ChuThich":"aqsas","MaDuong":"799","MaPhuong":"92","MaQuanHuyen":"26","MaTinhThanh":"16","KinhDo":"106.44275665283203","ViDo":"10.765457061021339"}');
				alert(objJSON);
				$.ajax({
					url: "http://localhost:1445/NhaTroService.svc/Add",
					type: "POST",
					contentType: "application/json; charset=utf-8",
					data: objJSON,
					success: function (msg) {
						alert('success');
					},
					error: function (msg) {
						alert(msg);
					}
				}); // end ajax sub
		}
</script>
<input type="button" value="Gui" onclick="sendJSON();" />
<input type="button" value="Gui2" onclick="InsertNhaTro();" />
</body>
</html>
